local sheyi = fk.CreateSkill {
  name = "mini__sheyi",
}

Fk:loadTranslationTable{
  ["mini__sheyi"] = "舍裔",
  [":mini__sheyi"] = "每轮限一次，当一名其他角色受到伤害时，若其体力值不大于你，你可以交给其X张牌，防止此伤害（X为你的体力值）。",

  ["#mini__sheyi-invoke"] = "舍裔：你可以交给 %dest %arg张牌，防止其受到的伤害",

  ["$mini__sheyi1"] = "世事有失有得，吾已心有所择。",
  ["$mini__sheyi2"] = "为保发儿无恙，妾身别无他法。",
}

sheyi:addEffect(fk.DetermineDamageInflicted, {
  anim_type = "support",
  can_trigger = function(self, event, target, player, data)
    return target ~= player and player:hasSkill(sheyi.name) and
      target.hp <= player.hp and #player:getCardIds("he") >= player.hp and player.hp > 0 and
      player:usedSkillTimes(sheyi.name, Player.HistoryRound) == 0
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local cards = room:askToCards(player, {
      min_num = player.hp,
      max_num = player.hp,
      include_equip = true,
      skill_name = sheyi.name,
      prompt = "#mini__sheyi-invoke::"..target.id..":"..player.hp,
      cancelable = true,
    })
    if #cards == player.hp then
      event:setCostData(self, {tos = {target}, cards = cards})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    data:preventDamage()
    player.room:moveCardTo(event:getCostData(self).cards, Card.PlayerHand, target, fk.ReasonGive, sheyi.name, nil, false, player)
  end,
})

return sheyi
